package gooj.server.services;

import java.util.List;

import gooj.client.services.UsersService;
import gooj.client.services.data.User;
import gooj.server.RulesHelper;
import gooj.server.data.UsersHelper;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@SuppressWarnings("serial")
public class UsersServiceImpl extends RemoteServiceServlet implements
	UsersService {

	@Override
	public User CreateUser(String session, String eMail, String login, Boolean isOwner) {
		RulesHelper.Check(session, "CreateUser");
		return UsersHelper.CreateUser(eMail, login, isOwner);
	}

	@Override
	public List<User> GetUsers(String session, int d, int count) {
		RulesHelper.Check(session, "GetUsers");
		return UsersHelper.GetUsers(d, count);
	}

	@Override
	public User Login(String login, String password) {
		return UsersHelper.Login(login, password);
	}

	@Override
	public void RemoveUser(String session, User user) {
		RulesHelper.Check(session, "RemoveUser");		
		UsersHelper.RemoveUser(user);
	}

	@Override
	public void SetPassword(String session, User user, String password) {
		RulesHelper.Check(session, "SetPassword");
		UsersHelper.SetPassword(user, password);		
	}

	@Override
	public User UpdateUser(String session, User user, String newEMail, String newlogin, Boolean newIsOwner) {
		RulesHelper.Check(session, "UpdateUser");
		return UsersHelper.UpdateUser(user, newEMail, newlogin, newIsOwner);
	}
}
